package com.hospital.servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hospital.model.YaoName;
import com.hospital.util.DbUtil;
@WebServlet("/manage/YaoShouJiaServlet")
public class YaoShouJiaServlet extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {//修改药品的价格
		// TODO Auto-generated method stub
		String method = request.getParameter("method");
		if ("modify".equals(method)) {
			int id = Integer.parseInt(request.getParameter("id"));
			String mname = request.getParameter("mname").trim();
			String money = request.getParameter("money").trim();
			String sql = "update t_medicinename set mname = '" + mname + "', money = '" + money + "' where id = " + id;
			DbUtil.add_modify(sql);
		}else if("modify_1".equals(method)) {
			int id = Integer.parseInt(request.getParameter("mname"));
			String money = request.getParameter("money").trim();
			String sql = "update t_medicinename set money = " + money + " where id = " + id;
			DbUtil.add_modify(sql);
		}
		request.getRequestDispatcher("/manage/yaoshoujia_info_manage.jsp").forward(request, response);
	}
}
